package Lee_code;

import java.util.*;

class Lee_49 {
    public List<List<String>> groupAnagrams(String[] strs) {
        HashMap<char[], List<String>> map = new HashMap<>();
        for(String str: strs)
        {
            char[] ch = str.toCharArray();
            Arrays.sort(ch);
            List<String> temp = new LinkedList<>();
            temp = map.getOrDefault(ch, new LinkedList<>());
            String key = new String(ch);
            temp.add(str);
            map.put(ch, temp);

        }
        return new ArrayList<>(map.values());
    }
}
